﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;

namespace employee.Controls
{
    public partial class emLanguageDetail : common.controls.baseUserControl
    {
        public emLanguageDetail()
        {
            InitializeComponent();
        }

        protected void SetDataSource(BindingSource dataSrc)
        {
            data.baseDS.emLangDataTable tbl = (data.baseDS.emLangDataTable)dataSrc.DataSource; 
            this.languageCb.DataBindings.Clear();

            common.BindingLibs.BindObject(this.languageCb, dataSrc, DataAccess.DataCache.myBaseDS.emLang.langCodeColumn.ColumnName);
            common.BindingLibs.BindObject(this.descriptionEd, dataSrc, DataAccess.DataCache.myBaseDS.emLang.descriptionColumn.ColumnName);
            descriptionEd.MaxLength = DataAccess.DataCache.myBaseDS.emLang.descriptionColumn.MaxLength;
        }

        public virtual void Init(BindingSource dataSrc) 
        {
            languageCb.LoadData();
            langLevelCb.LoadData();
            SetDataSource(dataSrc);
        }
        public virtual bool CheckData()
        {
            bool retVal = true;
            ClearNotifyError();
            //if (languageCb.myValue == "") 
            //{
            //    NotifyError(languageLbl);
            //    retVal = false;
            //}
            //if (langLevelCb.myValue == "")
            //{
            //    NotifyError(langLevelLbl);
            //    retVal = false;
            //}
            return retVal;
        }
        public virtual void LockEdit(bool state)
        {
            langLevelCb.Enabled = !state;
            languageCb.Enabled = !state;
            descriptionEd.ReadOnly = state;
        }
        public virtual void SetFocus()
        {
            this.Focus();
            languageCb.Focus();
        }
    }
}
